package com.zsl.sharp_team00b.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zsl.sharp_team00b.entity.Result;
import com.zsl.sharp_team00b.entity.User;
import com.zsl.sharp_team00b.mapper.UserMapper;
import com.zsl.sharp_team00b.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl
        extends ServiceImpl<UserMapper, User>
         implements UserService {

    @Autowired
    private  UserMapper mapper;

    @Autowired
    private Result result;

    @Override
    public Result login(User user) {

        QueryWrapper<User> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("username",user.getUsername())
                .eq("password",user.getPassword());
         Boolean success= mapper.exists(queryWrapper);

         result.setSuccess(success);

         return  result;

    }

    @Override
    public Result saveEntity(User user) {

        result.setSuccess(this.save(user));
        return  result;
    }
}
